<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<c:url value='/insdep/reset.min.css' />" rel="stylesheet" type="text/css">
	<link href="<c:url value='/insdep/easyui_full.css'/>" rel="stylesheet" type="text/css">
	<link href="<c:url value='/insdep/icon.css'/>" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<c:url value='/insdep/jquery-1.11.3.min.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/insdep/jquery.easyui-1.5.2.min.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/insdep/insdep-extend.min.js'/>"></script>
	
<title>创建新部门</title>
</head>
<body>
	<script type="text/javascript">
		$(function(){
			//自定义验证数字
			$.extend($.fn.validatebox.defaults.rules, {    
			    numberrule: {    
			        validator: function(value){    
			            return /^[1-9]\d*|0$/i.test(value);    
			        },    
			        message: '只能输入数字！'   
			    }    
			}); 
			/**
			 *关闭编辑窗口
			 */
			$("#close").linkbutton({
				onClick:function(){
					$("#position_info_win").window('close');
				}
			});
			/**
			 *提交表单并保存信息
			 */
			 $("#save").linkbutton({
				 onClick:function(){
					 $('#create_position').form({    
						    url:'give_addNewPosition',    
						    onSubmit: function(param){   
						    	param.deptid = $("#position_info_win").window("options").deptid
						    	return $(this).form("validate");//验证
						    },    
						    success:function(data){ 
						    	/**
						    	 *操作结果
						    	 */
						       if(data) {
									$("#position_info_win").window('close');
									$('#position_info_dg').datagrid('reload');
									//提示信息
									$.messager.show({
										title:'提示',msg:'保存信息成功！',timeout:1000,showType:'show',
										style:{
								            right:'', bottom:'' 
										}
									});
						        } else{
						        	//提示信息
						        	$.messager.show({
										title:'提示',msg:'保存信息失败', timeout:1000,showType:'show',
										style:{
								            right:'', bottom:'' 
										}
									});
						        }   
						    }    
						});    
						   
						$('#create_position').submit();  
				 }
			 });
			//初始化上级职位combobox
				$('#superPosition').combobox({                
					url : "find_LevelMaxPosition",
					queryParams: {
						"level" : $("#position_info_win").window("options").poslevel       
					}
				});
			//等级改变事件find_LevelMaxPosition
			$("#positionLevel").combobox({
				onChange:function(nval, oval){
					$("<form method='post'>").form({
						url:'find_LevelMaxPosition',
						onSubmit:function(param){
							param.level=nval
						},
						success:function(info){
							var reslut = $.parseJSON(info);
							$("#superPosition").combobox('loadData', reslut);
						}
					}).submit();
				}
			});
		});
	</script>
	<form id="create_position" >
		<div style="margin: 20px;">
			<input name="positionId" class="easyui-textbox" type="hidden"  > 
		</div>
		<div style="margin: 20px;">
			<input name="positionName" class="easyui-textbox" data-options="required:true" label="职位名称：" style="width:300px"> 
		</div>
		<div style="margin: 20px;">
			<select id="positionLevel" name="positionLevel" class="easyui-combobox" name="dept" label="职位等级：" data-options="valueField:'id',width:200, textField:'text', panelHeight:'auto'">
				<option value="1">等级一</option>   
    			<option value="2">等级二</option>   
    			<option value="3">等级三</option>   
    			<option value="4">等级四</option>   
    			<option value="5">等级五</option> 
			</select>  
		</div>
		<div style="margin: 20px;">
			<input id="superPosition" name="superPosition" class="easyui-combobox" name="dept" label="上级职位：" data-options="valueField:'id',width:200, textField:'text',panelHeight:'auto'"/>  
		</div>
		<div style="margin: 20px;">
			<input name="positionDesc" class="easyui-textbox" label="职位详情：" data-options="multiline:true,height:100"  style="width:300px"> 
		</div>
		<div style="margin: 20px;">
			<input name="positionOrgan" class="easyui-textbox" data-options="required:true,validType:'numberrule'" label="职位编制：" style="width:300px"> 
		</div>
		<div style="margin: 20px 105px;position: relative;top: 30px;">
			<a id="save" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>
			<a id="close" class="easyui-linkbutton" data-options="iconCls:'icon-no'" style="margin-left:30px;">取消</a>
		</div>
	</form>	
</body>
</html>